<style lang="scss" scoped>
@import "../../css/list.scss";
</style>

<template>
    <div class="collection full bgfff">
        <ul class="index_list padding-lr15 bgfff">
            <li class="flex-col border-b" v-for="(it,i) in list" @click="toRouter('houses_info/'+it.housesCode)">
                <div class="it_bg img-bg" :style="{backgroundImage:`url(${it.housesImgurl})`}"></div>
                <div class="it_info">
                    <div class="padding-b10">{{it.housesName}}</div>
                    <div class="font-12 c82 padding-b5 ">轻呼吸 · 慢生活 ·泉世界</div>
                    <div class="font-12 c82 padding-b10 ">成都周边-都江堰</div>
                    <div class="btn cred">
                        <i class="iconfont icon-dianhua1"></i>
                        <a :href="'tel:'+it.housesPhone" class="cred text-none">{{it.housesPhone}}</a>
                    </div>
                </div>
            </li>
        </ul>
    </div>
</template>

<script>
export default {
  name: "collection",
  data() {
    return {
      page: 0,
      pageSize: 10,
      totalPage: 0,
      list: []
    };
  },
  mounted() {
    let that = this;
    this.$nextTick(function() {
      that.getList();
    });
  },
  methods: {
    getList(has = false) {
      let that = this;
      let page = (this.page = ++this.page);
      if (has && page > this.totalPage) {
        this.layer("已加载全部", "m");
        return;
      }
      this.http
        .get("housescollect/list", {
          page: page,
          limit: that.pageSize
        })
        .then(res => {
          that.totalPage = res.data.totalPage;
          if (has) {
            that.list.push(res.data.list);
          } else {
            that.list = res.data.list;
          }
        })
        .catch(err => {});
    },

    //自定义函数
    toRouter(url) {
      this.$router.push({
        path: `/${url}`
      });
    }
  }
};
</script>

